import React, { Component } from 'react'
import { View, Image, Input, Editor, Text } from '@tarojs/components'
import Taro, { getEnv, showToast } from '@tarojs/taro'
import dayjs from "dayjs"
import './index.scss'
import '../images/public/style.css'
import { Dialog } from 'antd-mobile'
//公共组件
import LgNavCustomBar from '../../components/navCustomBar'
import LgInput from '../../components/input'
import LgButton from '../../components/button'

//个人组件
import PrTextarea from '../components/personal/textarea'
import PrPopCalendar from '../components/personal/popCalendar'
import PrPopRecord from '../components/personal/popRecord'
import PrSwitch from '../components/personal/switch'

//工具
import { getStorage, getBrowserController } from '../../components/utils'
import { getFileSystem } from '../../components/utils'
import MyUtils from '../components/personal/utils'
import { getNet } from '../../components/utils';
import { allfileIcon, codeType, noticeNatureLib, identityCodeLib, idCodeAdm, allIdentityCodeLib } from '../utils/Lib'
import getInfo from '../utils/getInfo'
import { getWxSDKParams } from "../../components/utils";
//api
import {
  API_saveNotice,//保存公告
  API_releaseNotice,//发布公告
  API_getEditDetail,//获取需要编辑的公告的信息
  API_noticeCheck,//敏感信息检测
  API_sensitiveData//获取敏感词
  // API_upload,//移动端批量上传文件
} from "../../../network/servers"
import { transmitUrlToVisit } from "../../../network/proxy"
import { AtNoticebar } from 'taro-ui'

import PrEditor from '../components/personal/editor'
// import wxSdk from '../utils/wxSdk'

if (process.env.TARO_ENV === 'h5') {
  if (getInfo.getEnv() === "weapp") {
    var wx = require('weixin-js-sdk')
  }
}

interface imgATTObject {
  attachmentId?: string//文件id，返回的时候才有
  url: string,//附件地址
  name: string,//附件名称
  size: number,//附件大小，单位（bit）
  type: number,//附件类型，1/文件；2/图片，3/音频，4/视频；5/其他
  orderNum: number//排序序号
}
interface imgObject {
  originalFileObj: { name: string, size: number, type: string }//图片信息
  path: string//图片路径
  size: number//图片大小
  type: string//图片类型
}

interface fileObject {
  name: string//文件名
  path: string//文件路径
  size: number//文件大小
  type: string//文件类型
}


interface IndexState {
  noticeId?: string//公告ID，没有表示新增加
  titleValue: string//标题内容
  contentValue: string//通知主体内容
  noticeType: 1 | 2//公告类型,   1:紧急通知，2：普通通知

  isPopCalendarOpen: boolean//日历弹窗是否开启
  isPopRecordOpen: boolean//录音弹窗是否关闭
  imgArr: imgObject[]//图片信息
  imgATTArr: imgATTObject[]//图片附件

  fileArr: fileObject[]//文件信息
  fileATTArr: imgATTObject[]//文件附件

  chooseDevice?: Object

  chooseObject?: Object//选择对象
  showChoObjString?: string//展示选择的对象字符串
  chooseArr?: Array<Object>

  chooseDevices?: any//选择设备
  showChoDevString?: string//展示选择的设备字符串

  isNeedConfirm?: boolean//是否需要确认
  // endTime?:{Date:string,Time:string}//结束时间、

  isNeedHandSign?: boolean //是否需要手签确认

  popCalendarType?: 1 | 2//1:开始弹窗，2:结束弹窗

  chooseStartDate?: string//弹窗开始日期
  chooseStartTime?: string//弹窗开始时间

  chooseEndDate?: string//弹窗结束日期
  chooseEndTime?: string//弹窗结束时间


  openAdvanced: boolean//是否打开高级设置

  noticeNature: number//公告种类 noticeNature:  1/校级；2/年级；3/班级；4/其他; 5/学校文件
  showNoticeNature?: boolean

  sensetiveData: Array<string>
}

export default class Index extends Component<any, IndexState> {
  constructor(props) {
    super(props)
    this.state = {
      titleValue: "",
      contentValue: "",
      noticeType: 1,
      isPopCalendarOpen: false,
      isPopRecordOpen: false,
      imgArr: [],
      imgATTArr: [],
      fileArr: [],
      fileATTArr: [],
      openAdvanced: false,
      noticeNature: 1,
      chooseDevices: {
        devics: [],
        RadioBroadcasts: [],
        buildingBoards: [],
        classBoard: []
      },
      sensetiveData: []
    }
    this.toChooseObject = this.toChooseObject.bind(this)
    this.toChooseDevices = this.toChooseDevices.bind(this)

    this.onInputAChange_title = this.onInputAChange_title.bind(this)//输入标题
    this.handleChange_content = this.handleChange_content.bind(this)//输入内容

    this.chooseNoticeNature = this.chooseNoticeNature.bind(this)

    this.chooseIMG = this.chooseIMG.bind(this)//选择图片
    this.chooseFile = this.chooseFile.bind(this)//选择文件
    this.chooseREC = this.chooseREC.bind(this)//选择音频

    this.uploadImage = this.uploadImage.bind(this)//上传图片

    this.openPopCalendar = this.openPopCalendar.bind(this)//打开日历弹窗
    this.closePopCalendar = this.closePopCalendar.bind(this)//关闭日历弹窗
    this.onConfirmCalendar = this.onConfirmCalendar.bind(this)//点击日历弹窗确定
    this.onDayChange = this.onDayChange.bind(this)//弹窗日期改变
    this.onTimeChange = this.onTimeChange.bind(this)//弹窗时间改变

    this.openPopRecord = this.openPopRecord.bind(this)//打开录音弹窗
    this.closePopRecord = this.closePopRecord.bind(this)//关闭录音弹窗
    this.onConfirmRecord = this.onConfirmRecord.bind(this)//录音弹窗完毕后执行

    this.isNeedConfirm = this.isNeedConfirm.bind(this)//是否需要确认
    this.isNeedHandSignConfirm = this.isNeedHandSignConfirm.bind(this)//是否需要手签确认

    this.saveNotice = this.saveNotice.bind(this)//保存公告
    this.issueNotice = this.issueNotice.bind(this)//发布公告

    //富文本编辑器
    this.editorInput = this.editorInput.bind(this)
    this.editorReady = this.editorReady.bind(this)
  }

  componentWillMount() {
    if (process.env.TARO_ENV === "h5" && getInfo.getEnv() == "weapp") {
      this.initWxSdk()
    }
  }

  componentDidMount() {
    this.getFromRoute()
    this.getSensetiveData()
    const { noticeNature = '' } = Taro.getCurrentInstance().router?.params || {}
    if (['1', '3'].includes(noticeNature)) {
      this.setState({
        noticeNature: parseInt(noticeNature),
      })
    }
  }

  componentWillUnmount() { }

  componentDidShow() {
    //选择对象页返回后处理
    let showChoObjArr = MyUtils.getStorage("showChoObjArr")
    let chooseObject = MyUtils.getStorage("chooseObject")

    console.log("didshow选择的对象", chooseObject)
    let arr = []
    if (showChoObjArr?.length > 0) {
      showChoObjArr.forEach(i => {
        if (i.hasOwnProperty('groupName')) {
          return arr.push(i.groupName)
        } else {
          return arr.push(i.userName)
        }
      })
    }
    if (showChoObjArr) {
      if (chooseObject) {
        this.setState({
          showChoObjString: arr.join("、"),
          chooseArr: chooseObject
        })
      }
      MyUtils.setStorage("showChoObjArr", undefined)
      MyUtils.setStorage("chooseObject", undefined)
    }



    // if (showChoDevArr) {
    //   if (chooseDevices) {
    //     console.log("chooseDevices有值", chooseDevices)
    //     this.setState({
    //       showChoDevString: Array.isArray(showChoDevArr) ? showChoDevArr.join("、") : showChoDevArr,
    //       chooseDevices
    //     })
    //   }
    //   MyUtils.setStorage("showChoDevArr", undefined)
    //   MyUtils.setStorage("chooseDevices", undefined)
    // }
  }

  componentDidHide() { }
  //路由=============================
  getFromRoute() {
    let toIssueNotice = MyUtils.getStorage("toIssueNotice")
    console.log("global-toIssueNotice", toIssueNotice)
    let identityCode = getInfo.getIdentityCode()

    if (!toIssueNotice.noticeId) {
      this.setState({
        noticeType: toIssueNotice.noticeType,
        showNoticeNature: toIssueNotice.noticeType == 1 ? false : (idCodeAdm.findIndex(item => item == identityCode) != -1) ? true : false,
        // noticeNature: (idCodeAdm.findIndex(item => item == identityCode) != -1) ? 1 : 3,
      })
    } else {
      this.api_getEditDetail(toIssueNotice.noticeId)
    }
  }

  toChooseObject() {
    console.log(this.state)
    // let showNoticeNature = this.state.showNoticeNature?true:false
    let noticeNature = this.state.noticeNature
    let obj = []
    if (this.state.chooseArr?.length > 0) {
      this.state.chooseArr?.forEach(i => {
        obj.push({
          userId: i.userId,
          userName: i.userName,
          avatarPath: i.avatarPath
        })
      })
    }
    let data = {
      noticeNature: noticeNature,
      receivers: this.state.chooseArr
    }
    console.log("跳转到选择对象页", data)
    MyUtils.setStorage("toChooseObject", data)
    MyUtils.setStorage("showChoDevArr", MyUtils.getStorage("showChoDevArr"))
    MyUtils.setStorage("chooseDevices", MyUtils.getStorage("chooseDevices"))
    Taro.navigateTo({
      url: '/pages/noticeApp/selectUser/index',
    })
  }
  toChooseDevices() {
    let devicList = this.state.chooseDevice
    console.log("跳转到选择设备页", devicList, this.state.chooseDevices)

    MyUtils.setStorage("toChooseDevices", {
      RadioBroadcasts: this.state.chooseDevices?.RadioBroadcasts || [],
      buildingBoards: this.state.chooseDevices?.buildingBoards || [],
      classBoard: this.state.chooseDevices?.classBoard || [],
      devics: devicList || [],
    })
    Taro.navigateTo({
      url: '/pages/noticeApp/chooseDevices/index',
    })
  }
  //数据请求=========================
  api_getEditDetail(noticeId) {
    let parmas = {
      noticeId
    }
    let header = {
      "Authorization": getInfo.getToken()
    }
    API_getEditDetail(parmas, header).then(res => {
      console.log("api-获取编辑公告详情", res)
      if (res.code == 200) {
        let attachments = res.data.attachments ? res.data.attachments : []
        let imageSuffix = ["png", "jpg", "jpeg"]
        let fileSuffix = ["doc", "pdf", "docx", "ppt", "pptx", "xls", "xlsx", "txt", "epub", 'apk', 'mp4', 'mp3', 'zip', 'm4a']
        let imgATTArr: imgATTObject[] = []
        let fileATTArr: imgATTObject[] = []
        attachments.map(item => {
          let suffix = MyUtils.getSuffix(item.name)
          if (imageSuffix.indexOf(suffix) != -1) {//图片
            let itemImg = { ...item }
            itemImg.url = this.replaceHost(itemImg.url)
            imgATTArr.push(itemImg)
            // imgATTArr.push(item)
          } else if (fileSuffix.indexOf(suffix) != -1) {//文件
            fileATTArr.push(item)
          } else {//未知文件
            console.log("读取到未知后缀文件", item)
            fileATTArr.push(item)
          }
        })
        let chooseObject = res.data.receivers
        let showChoObjString = ""
        let showChoDevString = ""
        let devicesArr: any = []
        let otherArr: any = []

        Object.keys(chooseObject).forEach(key => {
          if (key === 'devices') {
            devicesArr.push(chooseObject[key]);
          } else {
            otherArr.push(chooseObject[key]);
          }
        });

        devicesArr = devicesArr.flat()
        otherArr = otherArr.flat()

        let deviceStringArr = []
        let objStringArr = []

        if (devicesArr.length) {
          deviceStringArr = devicesArr.map(i => i.deviceName)
          objStringArr = otherArr.map(i => (i.userName || i.identityName || i.gradeName || i.groupName || i.className || i.subjectName || i.departmentName || i.collegeName || i.majorName))


          showChoObjString = objStringArr.join('、')
          showChoDevString = deviceStringArr.join('、')
        } else {
          let str = ''
          if (res.data.receivers.persons.length > 0) {
            res.data.receivers.persons.forEach(i => {
              if (str.length <= 0) {
                str = i.userName
              } else {
                str += `，${i.userName}`
              }
            })
          }
          showChoObjString = str
        }
        this.setState({
          chooseArr: res.data.receivers.persons
        })
        console.log(devicesArr, otherArr)
        MyUtils.setStorage('showChoDevString', objStringArr)



        let content = ""
        if (process.env.TARO_ENV === "weapp") {
          setTimeout(() => {
            this.editorInit(res.data.content)
          }, 500);
          content = res.data.content
        } else {
          content = res.data.content
          // content = MyUtils.getPlainText(res.data.content)
        }
        this.setState({
          noticeId: res.data.noticeId,
          titleValue: res.data.title,
          contentValue: content,
          noticeType: res.data.noticeType,
          noticeNature: res.data.noticeNature,
          chooseObject: chooseObject,
          showChoObjString: showChoObjString,
          chooseDevice: devicesArr,
          showChoDevString,
          chooseDevices: {
            ...this.state.chooseDevices,
            'devics': devicesArr
          },
          isNeedConfirm: res.data.readType == 1 ? false : true,//是否需要确认
          // endTime:{Date:res.data.endTime.split(" ")[0],Time:res.data.endTime.split(" ")[1]}//结束时间
          chooseStartDate: res.data.startTime?.split(" ")[0],
          chooseStartTime: res.data.startTime?.split(" ")[1],
          chooseEndDate: res.data.endTime?.split(" ")[0],
          chooseEndTime: res.data.endTime?.split(" ")[1],
          imgATTArr: imgATTArr,
          fileATTArr: fileATTArr,
        })
      }
    })
  }
  //IP地址替换
  replaceHost(url) {//替换外网IP或域名
    let baseUrl = MyUtils.getStorage("baseUrl220", false)
    if (!baseUrl) {
      return url
    }
    let hostOfBaseUrl: any = MyUtils.parseUrl(baseUrl)
    let newUrl = MyUtils.replaceHostOfUrl(url, hostOfBaseUrl.host, hostOfBaseUrl.port)
    return newUrl
  }
  //敏感内容检测======================
  checkValue(title, content) {
    return new Promise<any>((resolve, reject) => {
      let params = {
        openId: getInfo.getOpenId(),
        title: title,
        content: content,
        schoolId: getInfo.getSchoolId()
      }
      let header = {
        "Authorization": getInfo.getToken()
      }
      API_noticeCheck(params, header).then(res => {
        console.log("敏感内容检测结果", res)
        resolve(res)
      }).catch(res => {
        console.log("[x]敏感内容检测", res)
        resolve(res)
      })
    })
  }
  //WXsdk注册==========================
  async initWxSdk() {
    const params = await getWxSDKParams(['chooseImage', 'previewImage'])
    wx.config(params);
    wx.ready(function () {
      // config信息验证后会执行 ready 方法，所有接口调用都必须在 config 接口获得结果之后，config是一个客户端的异步操作，所以如果需要在页面加载时就调用相关接口，则须把相关接口放在 ready 函数中调用来确保正确执行。对于用户触发时才调用的接口，则可以直接调用，不需要放在 ready 函数中。
      console.log('WxSdk ready')
    });
    wx.error(function (res) {
      // config信息验证失败会执行 error 函数，如签名过期导致验证失败，具体错误信息可以打开 config 的debug模式查看，也可以在返回的 res 参数中查看，对于 SPA 可以在这里更新签名。
      console.log("wxSdk验证失败", res)
    });
  }
  //输入框===========================
  onInputAChange_title(value) {//标题输入
    this.setState({
      titleValue: value
    })
  }
  handleChange_content(value) {//内容输入
    this.setState({
      contentValue: value
    })
  }

  //富文本编辑器=============================================
  editorReady = e => {
    console.log("初始化", e)
    let that = this
    Taro.createSelectorQuery().select('#editor').context((res) => {
      console.log("rwwwww", res)
      that.editorCtx = res.context
    }).exec()
  }
  editorInit(htmlStr, num = 6) {//富文本编辑器
    if (this.editorCtx) {
      this.editorCtx.setContents({
        html: htmlStr
      })
    } else {
      if (num > 0) {
        console.log("富文本内容初始化失败，实例未获取，重新初始化")
        setTimeout(() => {
          this.editorInit(htmlStr, num - 1)
        }, 500);
      } else {
        console.log("富文本内容初始化失败，实例未获取")
      }
    }
  }

  editorCtx
  editorInput(e) {
    console.log("富文本内容改变", e)
    console.log("this", this)
    console.log("editorCtx", this.editorCtx)
    this.setState({
      contentValue: e.detail.html
    })
  }
  //图片==============================
  chooseIMG() {
    let fileNum = this.state.fileArr.length + this.state.fileATTArr.length
    let imgNum = this.state.imgArr.length + this.state.imgATTArr.length
    if (fileNum + imgNum >= 6) {
      Taro.showToast({
        title: "附件已达上限"
      })
      return
    }
    MyUtils.choosePic(6 - fileNum - imgNum).then((res: any) => {
      console.log("选择图片", res)
      let imgArr = [...this.state.imgArr, ...res.tempFiles]
      console.log("imgArr", imgArr)
      this.setState({
        imgArr
      })
    })
  }
  showpic(picPath) {//展示图片
    let imgArr = this.state.imgArr
    let imgATTArr = this.state.imgATTArr
    let arr = imgArr.map(item => {
      return item.path
    })
    let arr2 = imgATTArr.map(item => {
      return item.url
    })
    let picArr = [...arr2, ...arr]

    MyUtils.previewPic(picPath, picArr)
    // if(getInfo.getEnv() === "weapp"){//小程序嵌入h5
    //   wx.previewImage({
    //     current:picPath,// 当前显示图片的 http 链接
    //     urls:[picPath]// 需要预览的图片 http 链接列表
    //   })
    // }else{
    //   MyUtils.previewPic(picPath)
    // }
  }
  deletepic(e, key) {//删除图片
    e.stopPropagation()//禁止冒泡
    let imgArr = this.state.imgArr
    imgArr.splice(key, 1)
    this.setState({
      imgArr
    })
  }
  deletepic2(e, key) {//删除图片（已上传的图片）
    e.stopPropagation()//禁止冒泡
    let imgATTArr = this.state.imgATTArr
    imgATTArr.splice(key, 1)
    this.setState({
      imgATTArr
    })
  }
  uploadImage() {//上传图片
    let imgArr = this.state.imgArr
    let imgATTArr = this.state.imgATTArr
    console.log("imgArr", imgArr)
    let PromiseArr: any[] = []
    imgArr.map((item, index) => {
      PromiseArr.push(this.uploadOne(item.path, item.name, index + 1))
    })
    return new Promise<imgATTObject[]>(resolve => {
      Promise.all(PromiseArr).then(res => {
        res.map(item => {
          if (item.success) {
            let a = item.data[0]
            let newItem = {
              url: a.url,
              name: item.fileName,
              size: a.size,
              type: 1,
              orderNum: item.orderNum
            }
            imgATTArr.push(newItem)
          }
        })
        resolve(imgATTArr)
      })
    })
  }

  uploadOne(filePath, fileName, orderNum) {//上传一个文件（图片）
    let url
    if (process.env.TARO_ENV === 'h5') {
      if (getInfo.getEnv() === "weapp") {//微信小程序嵌入h5
        let baseUrl = MyUtils.getStorage("baseUrl220")
        url = baseUrl + 'edu-office-platform' + '/api/commons/file/upload'
        // url = baseUrl + '/api/commons/file/mobile/batch/upload'
        url = transmitUrlToVisit(url)
        console.log("代理url", url)
      } else {//app嵌入H5
        if (process.env.NODE_ENV === "development") {
          url = 'https://jdtest.aiedu100.com/edu-office-platform/api/commons/file/upload'
        } else {
          url = location.origin + '/edu-office-platform/api/commons/file/upload'
        }
      }
    } else {//微信小程序
      let baseUrl = MyUtils.getStorage("baseUrl220")
      let uploadUrl = baseUrl + 'edu-office-platform' + '/api/commons/file/upload'
      // let uploadUrl = baseUrl + '/api/commons/file/mobile/batch/upload'

      url = transmitUrlToVisit(uploadUrl)
      console.log("代理url", url)
    }
    return new Promise(resolve => {
      Taro.uploadFile({
        url: url,
        filePath: filePath,
        name: 'file',
        fileName: fileName,
        formData: {
          modelName: 'notice'
        },
        header: {
          "Authorization": getInfo.getToken()
        },
        success(res) {
          console.log("上传", res, "\ndata:", JSON.parse(res.data), "\nurl:", url, "\nfilePath:", filePath, "\nfileName:", fileName)
          if (res.statusCode == 200) {
            let a = JSON.parse(res.data)
            if (a.code == 200) {
              resolve({ success: true, data: a.data, orderNum, fileName })
            } else {
              resolve({ success: false, data: {}, orderNum })
            }
          } else {
            resolve({ success: false, data: {}, orderNum })
          }
        },
        fail(res) {
          resolve({ success: false, data: {}, orderNum })
        }
      })
    })
  }
  //公告种类==========================
  chooseNoticeNature() {//公告种类
    let that = this



    Taro.showActionSheet({
      itemList: noticeNatureLib,
      success: function (res) {
        let noticeNature = noticeNatureLib[res.tapIndex] == '班级通知' ? 3 : 1
        if (getInfo.getSchoolId() === "S-XHWLXX") {
          console.log('noticeNature', res.tapIndex * 1 + 1)
          noticeNature = res.tapIndex * 1 + 1
        }

        if (process.env.TARO_ENV === 'weapp') {
          noticeNature = res.tapIndex * 1 + 1
        }

        console.log(noticeNature, noticeNatureLib)
        that.setState({
          noticeNature,
          showChoObjString: "",
          chooseObject: undefined,
          showChoDevString: "",
          // chooseDevices: undefined
        })
      },
      fail: function () {
        noticeNatureLib
      }
    }).catch(err => console.log(err))
  }
  //选择文件==========================
  chooseFile() {//选择文件
    let fileNum = this.state.fileArr.length + this.state.fileATTArr.length
    let imgNum = this.state.imgArr.length + this.state.imgATTArr.length
    if (fileNum + imgNum >= 6) {
      Taro.showToast({
        title: "附件已达上限"
      })
      return
    }
    MyUtils.chooseFile({
      count: 6 - fileNum - imgNum,
      success: (res) => {
        console.log("选择文件", res)
        let fileArr = [...this.state.fileArr, ...res.tempFiles, ...this.state.imgArr]
        console.log("fileArr", fileArr)
        let imgList: any = []
        let fileList: any = []
        for (let item of fileArr) {
          console.log(item)
          if (item.type.includes('image') || item.type.includes('png')) {
            imgList.push(item)
          } else {
            fileList.push(item)
          }
        }
        this.setState({
          fileArr: fileList,
          imgArr: imgList
        })
      }
    })
  }

  deleteFile(e, key) {//删除文件
    e.stopPropagation()//禁止冒泡
    let fileArr = this.state.fileArr
    fileArr.splice(key, 1)
    this.setState({
      fileArr
    })
  }
  deleteFile2(e, key) {//删除文件（已上传文件）
    e.stopPropagation()//禁止冒泡
    let fileATTArr = this.state.fileATTArr
    fileATTArr.splice(key, 1)
    this.setState({
      fileATTArr
    })
  }
  uploadFile() {
    let fileArr = this.state.fileArr
    let fileATTArr = this.state.fileATTArr
    // let newImgATTArr = []
    let PromiseArr: any[] = []
    fileArr.map((item, index) => {
      PromiseArr.push(this.uploadOne(item.path, item.name, index + 1))
    })
    return new Promise<imgATTObject[]>(resolve => {
      Promise.all(PromiseArr).then(res => {
        // console.log("文件上传完毕",res)
        res.map(item => {
          if (item.success) {
            let a = item.data[0]
            let newItem = {
              url: a.url,
              name: item.fileName,
              size: a.size,
              type: 1,
              orderNum: item.orderNum
            }
            fileATTArr.push(newItem)
          }
        })
        resolve(fileATTArr)
      })
    })
  }
  //选择音频==========================
  chooseREC() {
    this.openPopRecord()
  }


  //开关按钮==========================
  isNeedConfirm(data) {//是否需要确认
    console.log("switch", !data)
    this.setState({
      isNeedConfirm: !data
    })
  }

  //开关按钮==========================
  isNeedHandSignConfirm(data) {//是否需要确认
    this.setState({
      isNeedHandSign: !data
    })
  }

  //日历弹窗==============================
  openPopCalendar(type: 1 | 2) {//打开弹窗,type:1:开始，2:结束
    console.log("type", type);
    this.setState({
      popCalendarType: type,
      isPopCalendarOpen: true
    })
  }
  closePopCalendar() {//关闭弹窗
    this.setState({
      isPopCalendarOpen: false
    })
  }
  onConfirmCalendar(Date, Time) {//点击确定
    console.log("弹窗确定", Date, Time)
    let popCalendarType = this.state.popCalendarType
    let newDate = dayjs(Date).format("YYYY-MM-DD")
    if (popCalendarType == 1) {//开始
      this.setState({
        chooseStartDate: newDate,
        chooseStartTime: Time,
        isPopCalendarOpen: false
      })
    } else {
      this.setState({
        chooseEndDate: newDate,
        chooseEndTime: Time,
        isPopCalendarOpen: false
      })
    }
  }
  onDayChange(value) {//日期改变
    let popCalendarType = this.state.popCalendarType
    let newDay = dayjs(value).format("YYYY-MM-DD")
    if (popCalendarType == 1) {
      let endDate = this.state.chooseEndDate
      console.log("endDate", endDate);
      let isAfter = dayjs(newDay).isAfter(endDate)
      if (!endDate || isAfter) {
        this.setState({
          chooseStartDate: newDay,
          chooseEndDate: newDay
        })
      } else {
        this.setState({
          chooseStartDate: newDay,
        })
      }
    } else {
      this.setState({
        chooseEndDate: newDay
      })
    }
  }

  onTimeChange(value) {//时间改变
    let popCalendarType = this.state.popCalendarType

    if (popCalendarType == 1) {
      // let endTime = this.state.chooseEndTime
      // console.log("value",value,endTime,popCalendarType);
      // if(!endTime || value > endTime){
      //   this.setState({
      //     chooseStartTime:value,
      //     chooseEndTime:value
      //   })
      // }else{
      this.setState({
        chooseStartTime: value
      })
      // }
    } else {
      // console.log("value2",value,popCalendarType);
      this.setState({
        chooseEndTime: value
      })
    }

  }
  //录音弹窗==========================
  openPopRecord() {
    this.setState({
      isPopRecordOpen: true
    })
  }
  closePopRecord() {
    this.setState({
      isPopRecordOpen: false
    })
  }
  onConfirmRecord(data) {
    console.log("录音完毕", data)
    this.setState({
      isPopRecordOpen: false
    })
  }

  //选择对象列表初始化=================
  IsTeaAdmin() {//判断是不是管理员身份的教师
    let identityCode = getInfo.getIdentityCode()
    let identityInfos = MyUtils.getStorage("userInfo").identityList

    console.log("身份：", identityCode, "identityInfos", identityInfos);
    let idIndex = identityInfos.findIndex(item => item.identityCode == identityCode)
    if (idIndex == -1) {//身份列表中没有这个身份
      console.log("个人身份列表中不包含该身份:", identityCode)
      return false
    }

    let identityItem = identityInfos[idIndex]
    if (identityItem.userType != undefined) {
      if (identityItem.userType.split(",").findIndex(item => item == "0") != -1) {
        return true
      }
    } else {//兼容旧版没有身份的userType的情况
      if (allIdentityCodeLib[identityCode] != undefined) {//判断是否是自定义身份
        if (idCodeAdm.indexOf(identityCode) != -1) {
          console.log("有管理权限身份:", identityCode);
          return true
        }
      }
    }
    return false

  }

  //保存与发布========================
  async saveNotice() {//保存
    Taro.showLoading({
      title: '保存中'
    })
    if (!this.state.titleValue) {
      this.showToast("请输入标题", "none", 2000)
      return
    }
    if (!this.state.contentValue) {
      this.showToast("请输入内容", "none", 2000)
      return
    }
    if (!this.state.showChoObjString && !this.state.showChoDevString) {
      this.showToast("请选择通知对象", "none", 2000)
      return
    }

    if (process.env.TARO_ENV === "weapp" && getInfo.getSchoolId() !== 'S-zjzx') {
      let checkValue = await this.checkValue(this.state.titleValue, this.state.contentValue)
      if (checkValue.desc == "请求资源不存在" || checkValue.code == undefined) {
        console.log("请求资源不存在");
      } else {
        if (checkValue.code != 200) {
          this.showToast(checkValue.msg, "none", 2000)
          return
        }
      }
    }
    let showChoObjString = this.state.showChoObjString//展示选择的对象字符串
    let showChoDevString = this.state.showChoDevString
    let receiverType = showChoObjString
    if (showChoObjString && showChoDevString) {
      receiverType = showChoObjString + '、' + showChoDevString
    } else if (showChoObjString) {
      receiverType = showChoObjString
    } else if (showChoDevString) {
      receiverType = showChoDevString
    }

    let chooseObject = JSON.parse(JSON.stringify(this.state.chooseObject || {}))
    let chooseDevices = JSON.parse(JSON.stringify(this.state.chooseDevices || {}))
    let devices: any = []
    console.log(chooseDevices)
    if (chooseDevices) {
      devices = [...chooseDevices.buildingBoards, ...chooseDevices.classBoard, ...chooseDevices.RadioBroadcasts, ...chooseDevices.devics]
    }

    chooseObject.devices = devices
    let isNeedConfirm = this.state.isNeedConfirm ? this.state.isNeedConfirm : false
    let isNeedHandSign = this.state.isNeedHandSign ? this.state.isNeedHandSign : false

    let chooseStartDate, chooseStartTime
    if (this.state.chooseStartDate || this.state.chooseStartTime) {
      chooseStartDate = dayjs(this.state.chooseStartDate).format("YYYY-MM-DD")
      chooseStartTime = dayjs(`${chooseStartDate} ${this.state.chooseStartTime}`).format("HH:mm:ss")
    }
    let chooseEndDate = this.state.chooseEndDate ? dayjs(this.state.chooseEndDate).format("YYYY-MM-DD") : dayjs().add(7, 'day').format("YYYY-MM-DD")
    let chooseEndTime = this.state.chooseEndTime ? dayjs(`${chooseEndDate} ${this.state.chooseEndTime}`).format("HH:mm:ss") : "23:59:59"
    if (dayjs(chooseStartDate + " " + chooseStartTime).isAfter(chooseEndDate + " " + chooseEndTime)) {
      this.showToast("结束时间不能在开始时间之前", "none", 2000)
      return
    }
    if (!dayjs(chooseEndDate + " " + chooseEndTime).isAfter(dayjs())) {
      this.showToast("截止时间必须是未来时间", "none", 2000)
      return
    }

    let noticeNature = this.state.noticeNature

    if (!this.IsTeaAdmin()) {
      noticeNature = 3
    }

    let res1: imgATTObject[] = await this.uploadImage()//上传图片
    console.log("图片上传成功", res1)
    let imgATTArr = res1
    let res2: imgATTObject[] = await this.uploadFile()//上传文件
    console.log("文件上传成功", res2)
    let fileATTArr = res2
    let identityObj = getInfo.getIdentity()
    let params: any = {
      // schoolType: getInfo.getSchoolType(),
      // noticeId: this.state.noticeId ? this.state.noticeId : "",
      title: this.state.titleValue,
      content: this.state.contentValue,
      noticeType: this.state.noticeType,
      eduType: '3',
      // noticeNature,//1/校级；2/年级；3/班级；4/其他; 5/学校文件
      // noticeClass: 1,//公告类别，1-学校端公告，2-局端公告，为空默认1
      receiverType,
      // replyType: isNeedConfirm ? 2 : 1,
      // sign:isNeedHandSign && isNeedConfirm?1:0,
      userId: getInfo.getUserId(),
      userName: getInfo.getUserName(),
      identityCode: identityObj.identityCode,
      identityName: identityObj.identityName,
      // startTime:chooseStartDate + " " + chooseStartTime,
      // startTime: "",
      // endTime: chooseEndDate + " " + chooseEndTime,
      // sysId: getInfo.getSysId(),
      // way: getInfo.whichWay(),
      // schoolId: getInfo.getSchoolId(),
      // schoolName: getInfo.getSchoolName(),
      receivers: chooseObject,
      attachments: [...imgATTArr, ...fileATTArr],//附件列表

    }
    if (chooseStartDate || chooseStartTime) {
      params.startTime = chooseStartDate + " " + chooseStartTime
    }
    // if(this.state.showNoticeNature){
    // params.noticeNature = this.state.noticeNature
    // }
    let header = {
      "Content-Type": "application/json",
      "Authorization": getInfo.getToken()
    }
    API_saveNotice(params, header).then(res => {
      console.log("API-保存公告:", res, "\nparams:", params)
      if (res.code == 200) {
        this.showToast("保存成功", "success", 2000)
        Taro.navigateBack({//回首页
          // delta: 1
        })
      } else {
        this.showToast(res.msg || "保存失败", "none", 2000)
      }
    }).catch((res) => {
      if (process.env.TARO_ENV === "h5") {
        this.showToast(res.msg || codeType[res.status] || "保存失败", "none", 2000)
      } else {
        this.showToast(res.msg, "none", 2000)
      }
    })
  }

  async issueNotice() {//发布
    Taro.showLoading({
      title: '发布中',
    })
    // if (!this.state.titleValue) {
    //   this.showToast("请输入标题", "none", 2000)
    //   return
    // }
    // if (!this.state.contentValue) {
    //   this.showToast("请输入内容", "none", 2000)
    //   return
    // }
    // if (!this.state.showChoObjString && !this.state.showChoDevString) {
    //   this.showToast("请选择通知对象", "none", 2000)
    //   return
    // }

    if (process.env.TARO_ENV === "weapp" && getInfo.getSchoolId() !== 'S-zjzx') {
      let checkValue = await this.checkValue(this.state.titleValue, this.state.contentValue)
      if (checkValue.desc == "请求资源不存在" || checkValue.code == undefined) {
        console.log("不存在检测敏感信息接口");//如果没这个接口就不检测了
      } else {
        if (checkValue.code != 200) {
          this.showToast(checkValue.msg, "none", 2000)
          return
        }
      }
    }

    let showChoObjString = this.state.showChoObjString//展示选择的对象字符串
    let showChoDevString = this.state.showChoDevString
    let receiverType = showChoObjString
    if (showChoObjString && showChoDevString) {
      receiverType = showChoObjString + '、' + showChoDevString
    } else if (showChoObjString) {
      receiverType = showChoObjString
    } else if (showChoDevString) {
      receiverType = showChoDevString
    }

    let chooseObject = JSON.parse(JSON.stringify(this.state.chooseObject || {}))
    console.log(this.state.chooseArr)
    let tempData = this.state.chooseArr || []
    let objData = []
    let nowData = {}
    const func = (obj) => {
      // if (obj.hasOwnProperty('structureVoList')) {
      obj.structureVoList.forEach(i => {
        if (i.hasOwnProperty('structureVoList')) {
          func(i)
        } else {
          i.parentGroupIds = nowData.parentGroupIds
          i.parents = nowData.parents
          i.parentGroupStr = nowData.parentGroupStr
          objData.push(i)
          return
        }
      })
      // }
    }
    if (tempData?.length > 0) {
      tempData.forEach(i => {
        if (i.hasOwnProperty('structureVoList')) {
          nowData = i
          func(i)
          // i.structureVoList.forEach(i2 => {
          //   i2.parentGroupIds = i.parentGroupIds
          //   i2.parents = i.parents
          //   i2.parentGroupStr = i.parentGroupStr
          //   objData.push(i2)
          // })
        } else {
          objData.push(i)
        }
      })
    }
    console.log(objData)
    let userList = {
      allList: [],
      classes: [],
      devices: [],
      grades: [],
      persons: objData
    };
    let chooseDevices = this.state.chooseDevices
    let devices: any = []
    if (chooseDevices) {
      devices = [...chooseDevices.buildingBoards, ...chooseDevices.classBoard, ...chooseDevices.RadioBroadcasts, ...chooseDevices.devics]
    }
    // chooseObject.devices = devices

    console.log("选择的接收者", chooseObject)

    // let endTime = this.state.endTime
    let isNeedConfirm = this.state.isNeedConfirm ? this.state.isNeedConfirm : false
    let isNeedHandSign = this.state.isNeedHandSign ? this.state.isNeedHandSign : false

    let chooseStartDate, chooseStartTime
    if (this.state.chooseStartDate || this.state.chooseStartTime) {
      chooseStartDate = dayjs(this.state.chooseStartDate).format("YYYY-MM-DD")
      chooseStartTime = dayjs(`${chooseStartDate} ${this.state.chooseStartTime}`).format("HH:mm:ss")
    }

    let chooseEndDate = this.state.chooseEndDate ? dayjs(this.state.chooseEndDate).format("YYYY-MM-DD") : dayjs().add(7, 'day').format("YYYY-MM-DD")
    let chooseEndTime = this.state.chooseEndTime ? dayjs(`${chooseEndDate} ${this.state.chooseEndTime}`).format("HH:mm:ss") : "23:59:59"
    if (dayjs(chooseStartDate + " " + chooseStartTime).isAfter(chooseEndDate + " " + chooseEndTime)) {
      this.showToast("结束时间不能在开始时间之前", "none", 2000)
      return
    }
    if (!dayjs(chooseEndDate + " " + chooseEndTime).isAfter(dayjs())) {
      this.showToast("截止时间必须是未来时间", "none", 2000)
      return
    }
    let res1 = await this.uploadImage()
    console.log("图片上传成功:", res1)
    let imgATTArr = res1
    let res2 = await this.uploadFile()
    console.log("文件上传成功:", res2)
    let fileATTArr = res2
    let identityObj = getInfo.getIdentity()

    let noticeNature = this.state.noticeNature

    if (!this.IsTeaAdmin()) {
      noticeNature = 3
    }


    let params: any = {
      // schoolType: getInfo.getSchoolType(),
      noticeId: this.state.noticeId ? this.state.noticeId : "",
      title: this.state.titleValue,
      content: this.state.contentValue,
      noticeType: this.state.noticeType,
      eduType: '3',
      // noticeNature,//1/校级；2/年级；3/班级；4/其他; 5/学校文件
      // noticeClass: 1,//公告类别，1-学校端公告，2-局端公告，为空默认1
      receiverType: MyUtils.getStorage("typeObjStr"),
      // replyType: isNeedConfirm ? 2 : 1,
      // sign:isNeedHandSign && isNeedConfirm?1:0,
      userId: getInfo.getUserId(),
      userName: getInfo.getUserName(),
      identityCode: identityObj.identityCode,
      identityName: identityObj.identityName,
      eduId: getInfo.getSchoolId(),
      // startTime:"",//加上会报错
      // endTime: chooseEndDate + " " + chooseEndTime,
      // sysId: getInfo.getSysId(),
      // way: getInfo.whichWay(),
      // schoolId: getInfo.getSchoolId(),
      // schoolName: getInfo.getSchoolName(),
      attachments: [...imgATTArr, ...fileATTArr],//附件列表
      receivers: userList
    }
    if (chooseStartDate || chooseStartTime) {
      params.startTime = chooseStartDate + " " + chooseStartTime
    }
    // if(this.state.showNoticeNature){
    //   params.noticeNature = this.state.noticeNature
    // }
    let header = {
      "Content-Type": "application/json",
      "Authorization": getInfo.getToken()
    }

    API_releaseNotice(params, header).then((res: any) => {
      console.log("API-发布公告:", res, "\nparams:", params)
      if (res.code == 200) {
        this.showToast("发布成功", "success", 2000)
        Taro.navigateBack({//回首页
          delta: 1
        })
      } else {
        this.showToast(res.msg, "none", 2000)
      }
    }).catch((res) => {
      if (process.env.TARO_ENV === "h5") {
        this.showToast(res.msg || codeType[res.status] || "发布失败", "none", 2000)
      } else {
        this.showToast(res.msg, "none", 2000)
      }
    })
  }
  //taro弹窗================================
  showToast(title, icon, duration) {
    Taro.hideLoading()
    setTimeout(() => {
      Taro.showToast({
        title: title,
        icon: icon,
        duration: duration
      })
    }, 500);
  }
  getSensetiveData = () => {

    let params = {
      eduId: getInfo.getSchoolId(),
    }

    let header = {
      // "Content-Type": "application/json",
      "Authorization": getInfo.getToken()
    }

    API_sensitiveData(params, header).then(res => {
      console.log("API-保存公告:", res, "\nparams:", params)
      if (res.code == 200) {
        this.setState({
          sensetiveData: Array.isArray(res.data) ? res.data : [],
        })
      } else {
      }
    }).catch((res) => {
      if (process.env.TARO_ENV === "h5") {
        // this.showToast(res.msg || codeType[res.status] || "获取敏感词失败", "none", 2000)
      } else {
        this.showToast(res.msg, "none", 2000)
      }
    })
  }
  showSensetive = () => {
    if (!this.state.titleValue) {
      this.showToast("请输入标题", "none", 2000)
      return
    }
    if (!this.state.contentValue) {
      this.showToast("请输入内容", "none", 2000)
      return
    }
    if (!this.state.showChoObjString && !this.state.showChoDevString) {
      this.showToast("请选择通知对象", "none", 2000)
      return
    }
    let sensetiveWord = []
    let sensetiveEditorContent = this.state.contentValue
    if (this.state.sensetiveData.length > 0) {
      this.state.sensetiveData.forEach((i, index) => {
        if (this.state.contentValue.includes(i)) {
          sensetiveWord.push(i)
          const regex = new RegExp(i, 'g')
          sensetiveEditorContent = sensetiveEditorContent.replace(regex, "*")
        }
      })
    }
    console.log(sensetiveEditorContent)
    if (sensetiveWord.length > 0) {
      Dialog.show({
        content: <div>(强制发布敏感词内容会被替换为<span style={{ color: "red" }}>*</span>,并且会给管理员发送消息提醒)</div>,
        closeOnAction: true,
        title: <div>通知内容含有敏感词<span style={{ color: "red" }}>"{sensetiveWord.toString()}"</span>，确认是否发布？</div>,
        actions: [
          // {
          //   key: 'online',
          //   text: '在线阅读',
          // },
          // {
          //   key: 'download',
          //   text: '下载文件',
          // },
          [
            {
              key: 'confirm',
              text: '确定',
              // bold: true,
            },
            {
              key: 'cancel',
              text: '再想想',
              // bold: true,
              danger: true,
            },
          ],
        ],
        onAction: (action) => {
          console.log(action)
          if (action.key == "confirm") {
            this.setState({
              contentValue: sensetiveEditorContent
            }, () => {
              this.issueNotice()
            })
          }
        }
      })

    } else {
      this.issueNotice()
    }
  }
  //========================================
  render() {
    let imgArr = this.state.imgArr
    let imgATTArr = this.state.imgATTArr
    let fileArr = this.state.fileArr
    let fileATTArr = this.state.fileATTArr

    let noticeType = this.state.noticeType//1:紧急通知，2：普通通知

    let showNoticeNature = this.state.showNoticeNature//是否展示公告种类
    let noticeNature = this.state.noticeNature//公告种类(number)

    let showChoObjString = this.state.showChoObjString//展示选择的对象字符串
    let showChoDevString = this.state.showChoDevString//展示选择的设备字符串

    let chooseStartDate = this.state.chooseStartDate
    let chooseStartTime = this.state.chooseStartTime

    let chooseEndDate = this.state.chooseEndDate ? this.state.chooseEndDate : dayjs().add(7, 'day').format("YYYY-MM-DD")//默认结束时间7天后
    let chooseEndTime = this.state.chooseEndTime ? this.state.chooseEndTime : "23:59:59"

    let titleValue = this.state.titleValue.toString()

    let isNeedConfirm = this.state.isNeedConfirm
    let isNeedHandSign = this.state.isNeedHandSign
    let env = getInfo.getEnv()

    let currentLabTab = noticeNatureLib[(noticeNature - 1) / 2]
    if (getInfo.getSchoolId() === 'S-XHWLXX') {
      currentLabTab = noticeNatureLib[noticeNature * 1 - 1]
    }

    return (
      <View className='issueNotice'>
        {
          env === "weapp" ? "" : (
            <LgNavCustomBar
              mainTitle={noticeType == 1 ? '发布紧急通知' : '发布部门通知'}
              needMainIcon={process.env.TARO_ENV === 'weapp' ? false : true}
              needBackIcon={true}
              isTitlePositionLeft={true}
              mainTitleBold={false}
            ></LgNavCustomBar>
          )
        }
        <View className='scroll'>

          <View className='titleInput'>
            <LgInput onChange={this.onInputAChange_title} value={titleValue} type="A" inputName="通知标题" placeholder="请输入通知标题" maxLength={50}></LgInput>
            {/* {
              showNoticeNature ?
                <View className='select_Box marginBottom30'>
                  <View className='select_item height102'>
                    <View className='attr'>通知类型</View>
                    <View className='right' onClick={this.chooseNoticeNature}>
                      {
                        process.env.TARO_ENV === 'weapp' ?
                          <View className={`text ${noticeNatureLib[noticeNature * 1 - 1] ? "black" : "gray"}`}>
                            {noticeNatureLib[noticeNature * 1 - 1] ? noticeNatureLib[noticeNature * 1 - 1] : "请选择"}
                          </View> :
                          <View className={`text ${currentLabTab ? "black" : "gray"}`}>
                            {currentLabTab? currentLabTab : "请选择"}
                          </View>
                      }
                      <View className='icon icon-b01901'></View>
                    </View>
                  </View>
                </View>
                : ""
            } */}
          </View>

          <View className='notice_content'>
            <View className='contentInput'>
              {/* <PrTextarea 
                className='contentInput_textarea'
                onChange={this.handleChange_content} 
                value={this.state.contentValue} 
                type="B" 
                inputName="标题" 
                placeholder="请输入通知内容"
                maxLength={10000} 
              ></PrTextarea> */}

              {/* 富文本：如果是小程序，请把H5的富文本注释掉，不然会报错 */}
              {
                process.env.TARO_ENV === "h5" ?
                  <PrEditor
                    htmlStr={this.state.contentValue}
                    placeholder={"请输入通知内容"}
                    hideTool
                    onChange={(html) => this.setState({ contentValue: html })}
                    className="editorbox"
                    className_editor="className_editor"
                  ></PrEditor>
                  :
                  <Editor
                    id='editor'
                    className='contentInput_editor'
                    placeholder={"请输入通知内容"}
                    onReady={this.editorReady}
                    onInput={this.editorInput}
                  ></Editor>
              }
            </View>
            {/* 
            <View className='choose_document_box'>
              <View className='choose_document'> */}
            <View className='file_container'>
              <View className='file_container_top'>
                {/* <View className='chooseIMG_btn' onClick={this.chooseIMG}></View> */}
                {/* <View className='chooseDOC_btn' onClick={this.chooseFile}></View> */}
                <Text className='file_text'>附件{imgArr.length + fileArr.length > 0 ?
                  <Text className='file_num'>({imgArr.length + fileArr.length}个附件)</Text>
                  : ''}</Text>
                <View className='file_container_icon' onClick={() => { this.chooseFile() }}><Text className='addIcon'></Text></View>
              </View>
              {/* {
                imgATTArr.length > 0 ? */}
              <View className='show_cho_img' style={{ marginTop: fileArr.length > 0 || imgArr.length > 0 ? '12px' : 0 }}>
                {
                  imgATTArr.map((item, index) => {
                    return (
                      item.attachmentId ?
                        <View className='addpic_item_box' key={"imgATTArr" + item.attachmentId}>
                          <Image className='addpic_item' src={item.url} mode="aspectFill" onClick={() => this.showpic(item.url)}></Image>
                          <View className='deletepic_icon' onClick={(e) => this.deletepic2(e, index)}></View>
                        </View>
                        : ""
                    )
                  })
                }
                {
                  imgArr.map((item, index) => {
                    return (
                      <View className='addpic_item_box' key={"img-" + index}>
                        <Image className='addpic_item' src={item.path} mode="aspectFill" onClick={() => this.showpic(item.path)}></Image>
                        <View className='deletepic_icon' onClick={(e) => this.deletepic(e, index)}></View>
                      </View>
                    )
                  })
                }
              </View>
              {/* : ''
              } */}

              <View className='show_cho_document'>

                {
                  fileATTArr.map((item, index) => {
                    let svgIcon = allfileIcon[MyUtils.getSuffix(item.name)]
                    return (
                      <View className='item' key={"fileATTArr" + item.attachmentId}>
                        <View className={`icon_file ${svgIcon ? "prIcon_" + svgIcon : "prIcon_0a01101"}`}></View>
                        <View className='doc_name'>{item.name}</View>
                        <View className='deletepic_icon' onClick={(e) => this.deleteFile2(e, index)}></View>
                      </View>
                    )
                  })
                }
                {
                  fileArr.map((item, index) => {
                    let svgIcon = allfileIcon[MyUtils.getSuffix(item.name)]
                    return (
                      <View className='item' key={"file-" + index}>
                        <View className={`icon_file ${svgIcon ? "prIcon_" + svgIcon : "prIcon_0a01101"}`}></View>
                        <View className='doc_name'>{item.name}</View>
                        <View className='deletepic_icon' onClick={(e) => this.deleteFile(e, index)}></View>
                      </View>
                    )
                  })
                }
              </View>

              <View className='show_cho_record'>
              </View>

            </View>
          </View>

          <View className='select_Box'>
            <View className='select_item'>
              <View className='attr'>通知对象</View>
              <View className='right' onClick={this.toChooseObject}>
                <View className={`text ${showChoObjString ? "black" : "gray"}`}>
                  {showChoObjString ? showChoObjString : "请选择"}
                </View>
                <View className='icon icon-b01901'></View>
              </View>
            </View>
            {/* <View className='select_item borderTop1px'>
              <View className='attr'>选择设备</View>
              <View className='right' onClick={this.toChooseDevices}>
                <View className={`text ${showChoDevString ? "black" : "gray"}`}>
                  {showChoDevString ? showChoDevString : "请选择"}
                </View>
                <View className='icon icon-b01901'></View>
              </View>
            </View> */}
            {/* <View className='isNeedC'>
              <View className='attr'>是否需要确认</View>
              <View className='right'>
                <PrSwitch
                  value={isNeedConfirm}
                  onClick={this.isNeedConfirm}
                ></PrSwitch>
              </View>
            </View>
            {isNeedConfirm&&<View className='isNeedC'>
              <View className='attr'>确认是否需要签名</View>
              <View className='right'>
                <PrSwitch
                  value={isNeedHandSign}
                  onClick={this.isNeedHandSignConfirm}
                ></PrSwitch>
              </View>
            </View>} */}
          </View>

          {/* <View className='setting_btn' onClick={() => this.setState({ openAdvanced: !this.state.openAdvanced })}>
            <View className='text'>高级设置</View>
            <View className={`icon icon-b01901 ${this.state.openAdvanced ? "rotate90" : ""}`}></View>
          </View> */}

          <View className={`select_Box Advanced ${this.state.openAdvanced ? "open marginBottom30" : "close"}`}>
            <View className='select_time'>
              <View className='attr'>开始时间</View>
              <View className='right' onClick={() => this.openPopCalendar(1)}>
                <View className={`text ${chooseStartDate ? "black" : "gray"}`}>{chooseStartDate ? `${chooseStartDate}\xa0\xa0\xa0${chooseStartTime}` : "请选择"}</View>
                <View className='icon icon-b01901'></View>
              </View>
            </View>
            <View className='select_time borderTopLine'>
              <View className='attr'>结束时间</View>
              <View className='right' onClick={() => this.openPopCalendar(2)}>
                <View className='text black'>{`${chooseEndDate}\xa0\xa0\xa0${chooseEndTime}`}</View>
                <View className='icon icon-b01901'></View>
              </View>
            </View>
          </View>

        </View>

        <View className='issueNotice_btnBox'>
          <LgButton className='btn_issue' type='B' onClick={this.saveNotice}>保存</LgButton>
          <LgButton className='btn_issue' type='B' onClick={this.showSensetive}>发布</LgButton>
        </View>

        {/* 弹窗 */}

        <PrPopCalendar
          isOpen={this.state.isPopCalendarOpen}
          onClosePop={this.closePopCalendar}//关闭弹窗
          onConfirm={this.onConfirmCalendar}//点击确定
          popCalendarType={this.state.popCalendarType}
          chooseDate={this.state.popCalendarType == 2 ? this.state.chooseEndDate : this.state.chooseStartDate}//日期
          chooseTime={this.state.popCalendarType == 2 ? chooseEndTime : chooseStartTime}//时间
          onDayChange={this.onDayChange}//改变日期
          onTimeChange={this.onTimeChange}//改变时间
        ></PrPopCalendar>

        <PrPopRecord
          isOpen={this.state.isPopRecordOpen}
          onClosePop={this.closePopRecord}//关闭弹窗
          onConfirm={this.onConfirmRecord}//录音完毕后执行
        ></PrPopRecord>

      </View>
    )
  }
}
